package computacaografica;

public class PontoNormal {

	private double xNorm, yNorm;

	public PontoNormal(double xN, double yN) {
		if (xN > 1D) {
			xN = 1D;
		} else if (xN < 0D) {
			xN = 0D;
		}

		if (yN > 1D) {
			yN = 1D;
		} else if (yN < 0D) {
			yN = 0D;
		}

		this.xNorm = xN;
		this.yNorm = yN;
	}

	public double getXNorm() {
		return xNorm;
	}

	public double getYNorm() {
		return yNorm;
	}

	public PontoCart toCart() {
		int x = (int) Math.round(this.xNorm
				* (PontoCart.MAX_X - PontoCart.MIN_X) + PontoCart.MIN_X);

		int y = (int) Math.round(this.yNorm
				* (PontoCart.MAX_Y - PontoCart.MIN_Y) + PontoCart.MIN_Y);

		return new PontoCart(x, y);
	}

	public Ponto toDisp() {
		int xD = (int) Math.round(this.xNorm * (Ponto.ndh - 1));

		int yD = (int) Math.round(this.yNorm * (Ponto.ndv - 1));

		return new Ponto(xD, yD);
	}
}
